<?php require_once('../Connections/agriculture.php'); ?>
<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
        case "text":
            $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
            break;
        case "long":
        case "int":
            $theValue = ($theValue != "") ? intval($theValue) : "NULL";
            break;
        case "double":
            $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
            break;
        case "date":
            $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
            break;
        case "defined":
            $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
            break;
    }
    return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
    $updateSQL = sprintf("UPDATE seeding SET seeding_crop=%s, seeding_choice=%s, seeding_disinfect=%s, seeding_stroma=%s, seeding_sow_time=%s, seeding_sow_light=%s, seeding_sow_temp=%s, seeding_sow_water=%s, seeding_grow_term=%s, seeding_grow_light=%s, seeding_grow_dtemp=%s, seeding_grow_ntemp=%s, seeding_grow_water=%s, seeding_young_term=%s, seeding_young_light=%s, seeding_young_dtemp=%s, seeding_young_ntemp=%s, seeidng_young_water=%s WHERE seeding_id=%s", GetSQLValueString($_POST['area1'], "text"), GetSQLValueString($_POST['area2'], "text"), GetSQLValueString($_POST['area3'], "text"), GetSQLValueString($_POST['area4'], "text"), GetSQLValueString($_POST['area5'], "text"), GetSQLValueString($_POST['area6'], "text"), GetSQLValueString($_POST['area7'], "text"), GetSQLValueString($_POST['area8'], "text"), GetSQLValueString($_POST['area9'], "text"), GetSQLValueString($_POST['area10'], "text"), GetSQLValueString($_POST['area11'], "text"), GetSQLValueString($_POST['area12'], "text"), GetSQLValueString($_POST['area13'], "text"), GetSQLValueString($_POST['area14'], "text"), GetSQLValueString($_POST['area15'], "text"), GetSQLValueString($_POST['area16'], "text"), GetSQLValueString($_POST['area17'], "text"), GetSQLValueString($_POST['area18'], "text"), GetSQLValueString($_POST['hiddenField'], "int"));

    mysql_select_db($database_agriculture, $agriculture);
    $Result1 = mysql_query($updateSQL, $agriculture) or die(mysql_error());
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
    $updateSQL = sprintf("UPDATE seeding SET seeding_crop=%s, seeding_choice=%s, seeding_disinfect=%s, seeding_stroma=%s, seeding_sow_time=%s, seeding_sow_light=%s, seeding_sow_temp=%s, seeding_sow_water=%s, seeding_grow_term=%s, seeding_grow_light=%s, seeding_grow_dtemp=%s, seeding_grow_ntemp=%s, seeding_grow_water=%s, seeding_young_term=%s, seeding_young_light=%s, seeding_young_dtemp=%s, seeding_young_ntemp=%s, seeidng_young_water=%s WHERE seeding_id=%s", GetSQLValueString($_POST['area1'], "text"), GetSQLValueString($_POST['area2'], "text"), GetSQLValueString($_POST['area3'], "text"), GetSQLValueString($_POST['area4'], "text"), GetSQLValueString($_POST['area5'], "text"), GetSQLValueString($_POST['area6'], "text"), GetSQLValueString($_POST['area7'], "text"), GetSQLValueString($_POST['area8'], "text"), GetSQLValueString($_POST['area9'], "text"), GetSQLValueString($_POST['area10'], "text"), GetSQLValueString($_POST['area11'], "text"), GetSQLValueString($_POST['area12'], "text"), GetSQLValueString($_POST['area13'], "text"), GetSQLValueString($_POST['area14'], "text"), GetSQLValueString($_POST['area15'], "text"), GetSQLValueString($_POST['area16'], "text"), GetSQLValueString($_POST['area17'], "text"), GetSQLValueString($_POST['area18'], "text"), GetSQLValueString($_POST['hiddenField'], "int"));

    mysql_select_db($database_agriculture, $agriculture);
    $Result1 = mysql_query($updateSQL, $agriculture) or die(mysql_error());

    $updateGoTo = "dryumiao.php";
    if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= ( strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $updateGoTo));
}

$colname_editRecordset1 = "-1";
if (isset($_GET['id'])) {
    $colname_editRecordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_agriculture, $agriculture);
$query_editRecordset1 = sprintf("SELECT * FROM seeding WHERE seeding_id = %s", $colname_editRecordset1);
$editRecordset1 = mysql_query($query_editRecordset1, $agriculture) or die(mysql_error());
$row_editRecordset1 = mysql_fetch_assoc($editRecordset1);
$totalRows_editRecordset1 = mysql_num_rows($editRecordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>修改育苗信息</title>
        <style type="text/css">
            <!--
            .STYLE1 {font-size: 14px}
            -->
        </style>
    </head>
<?php
if ($_GET["id"]) {
    
}
?>
    <body>
        <span class="STYLE1"><a href="dryumiao.php">返回</a></span>
        <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="STYLE1" id="form1">
            <table width="400" border="1" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td><div align="center">ID</div></td>
                    <td><?php echo $row_editRecordset1['seeding_id']; ?></td>
                </tr>
                <tr>
                    <td width="53"><div align="center">名称</div></td>
                    <td width="141"><label>
                            <input name="area1" type="text" id="area1" value="<?php echo $row_editRecordset1['seeding_crop']; ?>" />
                        </label></td>
                </tr>
                <tr>
                    <td><div align="center">壮苗选择</div></td>
                    <td><label>
                            <textarea name="area2" id="area2"><?php echo $row_editRecordset1['seeding_choice']; ?></textarea>
                        </label></td>
                </tr>
                <tr>
                    <td><div align="center">种子消毒</div></td>
                    <td><label>
                            <textarea name="area3" id="area3"><?php echo $row_editRecordset1['seeding_disinfect']; ?></textarea>
                        </label></td>
                </tr>
                <tr>
                    <td><div align="center">基质配比</div></td>
                    <td><label>
                            <textarea name="area4" id="area4"><?php echo $row_editRecordset1['seeding_stroma']; ?></textarea>
                        </label></td>
                </tr>
                <tr>
                    <td><div align="center">播种时间</div></td>
                    <td><textarea name="area5" id="area5"><?php echo $row_editRecordset1['seeding_sow_time']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">播种光照</div></td>
                    <td><textarea name="area6" id="area6"><?php echo $row_editRecordset1['seeding_sow_light']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">播种温度</div></td>
                    <td><textarea name="area7" id="area7"><?php echo $row_editRecordset1['seeding_sow_temp']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">播种水分</div></td>
                    <td><textarea name="area8" id="area8"><?php echo $row_editRecordset1['seeding_sow_water']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">发芽时长</div></td>
                    <td><textarea name="area9" id="area9"><?php echo $row_editRecordset1['seeding_grow_term']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">发芽光照</div></td>
                    <td><textarea name="area10" id="area10"><?php echo $row_editRecordset1['seeding_grow_light']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">发芽日温</div></td>
                    <td><textarea name="area11" id="area11"><?php echo $row_editRecordset1['seeding_grow_dtemp']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">发芽夜温</div></td>
                    <td><textarea name="area12" id="area12"><?php echo $row_editRecordset1['seeding_grow_ntemp']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">发芽水分</div></td>
                    <td><textarea name="area13" id="area13"><?php echo $row_editRecordset1['seeding_grow_water']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">幼苗期时长</div></td>
                    <td><textarea name="area14" id="area14"><?php echo $row_editRecordset1['seeding_young_term']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">幼苗期光照</div></td>
                    <td><textarea name="area15" id="area15"><?php echo $row_editRecordset1['seeding_young_light']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">幼苗期日温</div></td>
                    <td><textarea name="area16" id="area16"><?php echo $row_editRecordset1['seeding_young_dtemp']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">幼苗期夜温</div></td>
                    <td><textarea name="area17" id="area17"><?php echo $row_editRecordset1['seeding_young_ntemp']; ?></textarea></td>
                </tr>
                <tr>
                    <td><div align="center">幼苗期水分</div></td>
                    <td><textarea name="area18" id="area18"><?php echo $row_editRecordset1['seeidng_young_water']; ?></textarea></td>
                </tr>
                <tr>
                    <td colspan="2"><div align="center">
                            <label>
                                <input type="submit" name="Submit" value="提交" /> 
                                &nbsp;&nbsp;&nbsp;&nbsp; </label>
                            <label>
                                <input type="reset" name="Submit2" value="重置" />
                            </label>
                        </div></td>
                </tr>
            </table>
            <input name="hiddenField" type="hidden" value="<?php echo $_GET["id"]; ?>" />
            <p>
                <input type="hidden" name="MM_update" value="form1">
                    </form>
                    </body>
                    </html>
<?php
mysql_free_result($editRecordset1);
?>
